import 'package:flutter/material.dart';
import 'package:flutter_ui/common/app_theme.dart';

/// 个人设置页面
class ProfilePage extends StatelessWidget {
  const ProfilePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('个人设置'),
        centerTitle: true,
        actions: [
          IconButton(onPressed: () {}, icon: const Icon(Icons.share_outlined)),
        ],
      ),
      body: SingleChildScrollView(
        child: Column(
          children: [
            // 个人信息卡片
            _buildProfileCard(),
            const SizedBox(height: 16),
            // 设置项列表
            _buildSettingItem(Icons.local_hospital_outlined, '切换病区', true),
            _buildSettingItem(Icons.notifications_outlined, '消息推送设置', true),
            _buildSettingItem(Icons.smart_toy_outlined, 'AI介入设置', true),
            _buildSettingItem(Icons.data_usage_outlined, '同步数据', true),
            _buildSettingItem(Icons.cloud_upload_outlined, '本地数据上传', true, rightText: '6条数据上传失败'),
            _buildSettingItem(Icons.cleaning_services_outlined, '本地缓存清理', true, rightText: '缓存360kb'),
            _buildSettingItem(Icons.system_update_outlined, '程序更新', true, rightText: '最新V1.2.3'),
            _buildSettingItem(Icons.password_outlined, '修改密码', true),
            _buildSettingItem(Icons.settings_outlined, '设置服务器IP', true),
          ],
        ),
      ),
    );
  }

  /// 构建个人信息卡片
  Widget _buildProfileCard() {
    return Container(
      padding: const EdgeInsets.all(16),
      color: Colors.white,
      child: Row(
        children: [
          // 头像
          CircleAvatar(
            radius: 30,
            backgroundColor: AppTheme.primaryColor.withOpacity(0.1),
            child: const Icon(
              Icons.person,
              size: 36,
              color: AppTheme.primaryColor,
            ),
          ),
          const SizedBox(width: 16),
          // 个人信息
          Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: const [
                Text(
                  '妙护士 | 副主任护师',
                  style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
                ),
                SizedBox(height: 4),
                Text(
                  '心血管内科二病区',
                  style: TextStyle(color: Colors.grey),
                ),
              ],
            ),
          ),
          // 编辑按钮
          IconButton(
            onPressed: () {},
            icon: const Icon(Icons.edit_outlined),
          ),
        ],
      ),
    );
  }

  /// 构建设置项
  Widget _buildSettingItem(IconData icon, String title, bool showArrow, {String? rightText}) {
    return Container(
      padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
      decoration: BoxDecoration(
        color: Colors.white,
        border: Border(bottom: BorderSide(color: Colors.grey[200]!)),
      ),
      child: Row(
        children: [
          Icon(icon, color: Colors.grey),
          const SizedBox(width: 12),
          Text(title),
          const Spacer(),
          if (rightText != null)
            Text(
              rightText,
              style: const TextStyle(color: Colors.grey, fontSize: 12),
            ),
          if (showArrow) const Icon(Icons.chevron_right, color: Colors.grey),
        ],
      ),
    );
  }
}